<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<link rel="stylesheet" type="text/css" href="http://cdn.amazeui.org/amazeui/2.7.2/css/amazeui.css">

<?php
/**
 * Created by PhpStorm.
 * User: dapeng
 * Date: 2018/9/27
 * Time: 下午2:49
 */
$pdo = new PDO("mysql:dbname=test;host=localhost","root",'');
$pdo->exec("SET NAMES 'utf8'");

//$sql = "SELECT * FROM dc_user;";
$sql2="SELECT * FROM tbl_user
WHERE id = 2;";

//$res = $pdo->query($sql);
$res2 = $pdo->query($sql2);

echo "<table border='1' class=\"am-table am-table-striped am-table-hover\" >";

echo "<tr>
<th>编号</th>
<th>名字</th>
<th>电话</th>
<th>性别</th>
<th>年龄</th>

</tr>";
//遍历数据库里面得到的结果
foreach ($res2 as $user){
    echo "<tr>";
    echo "<td>{$user['id']}</td>";
    echo "<td>{$user['name']}</td>";
    echo "<td>{$user['tel']}</td>";
    echo "<td>{$user['sex']}</td>";
    echo "<td>{$user['age']}</td>";

    echo "</tr>";

}